From: Barnabás Pőcze Date: Sun, 5 Nov 2023 01:49:34 +0000 (+0100) Subject: st/texture-cache: Always close GdkPixbufLoader before disposal X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~281^2~2^2~322 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3e7027821df103816ba7379fd1782053ab92894d;p=gnome-shell.git st/texture-cache: Always close GdkPixbufLoader before disposal As per the warning emitted when destroying without closing first GdkPixbufLoader finalized without calling gdk_pixbuf_loader_close() - this is not allowed. You must explicitly end the data stream to the loader before dropping the last reference. closing it is necessary. Create the GdkPixbufLoader after loading the file contents so that the loader is guaranteed to be closed before it is destroyed. (`gdk_pixbuf_loader_write()` closes it on failure.) Part-of: --- diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c index 2986f5bb3..8d773dabb 100644 --- a/src/st/st-texture-cache.c +++ b/src/st/st-texture-cache.c @@ -1381,7 +1381,7 @@ load_sliced_image (GTask *result, GdkPixbuf *pix; gint width, height, y, x; gint scale_factor; - GdkPixbufLoader *loader; + GdkPixbufLoader *loader = NULL; GError *error = NULL; gchar *buffer = NULL; gsize length; @@ -1391,15 +1391,15 @@ load_sliced_image (GTask *result, data = task_data; g_assert (data); - loader = gdk_pixbuf_loader_new (); - g_signal_connect (loader, "size-prepared", G_CALLBACK (on_loader_size_prepared), data); - if (!g_file_load_contents (data->gfile, cancellable, &buffer, &length, NULL, &error)) { g_warning ("Failed to open sliced image: %s", error->message); goto out; } + loader = gdk_pixbuf_loader_new (); + g_signal_connect (loader, "size-prepared", G_CALLBACK (on_loader_size_prepared), data); + if (!gdk_pixbuf_loader_write (loader, (const guchar *) buffer, length, &error)) { g_warning ("Failed to load image: %s", error->message); @@ -1428,7 +1428,7 @@ load_sliced_image (GTask *result, out: /* We don't need the original pixbuf anymore, which is owned by the loader, * though the subpixbufs will hold a reference. */ - g_object_unref (loader); + g_clear_object (&loader); g_free (buffer); g_clear_pointer (&error, g_error_free); g_task_return_pointer (result, res, free_glist_unref_gobjects);